cmake_minimum_required(VERSION 3.10)
set(projectName Prog2_1_background)#工程名字
message(STATUS "camke:" ${projectName})
project(${projectName})
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
file(GLOB_RECURSE contain_sources *.cpp *.hpp *.h)
add_executable(${projectName} ${contain_sources})


target_include_directories(${projectName} PUBLIC .
                                   ${DEPS_DIR}/glew/include
                                   ${DEPS_DIR}/glm
                                   ${DEPS_DIR}/SOIL2-1.31
                                   ${DEPS_DIR}/glfw/include
                                   )
#target_link_directories(${projectName} PUBLIC ${DEPS_LIB})
target_link_libraries(${projectName} PUBLIC
${DEPS_DIR}/lib/glfw3.lib
${DEPS_DIR}/lib/glfw3dll.lib
${DEPS_DIR}/lib/glew.lib#cpp first #define GLEW_STATIC  _imp glewInit
${DEPS_DIR}/lib/soil2.lib
OpenGL32#__imp__glClear
)

#add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
#    COMMAND ${CMAKE_COMMAND} -E copy
#    ${BUILD_3RD_DEPS_DIR}/renderdoc/renderdoc.dll ${EXECUTABLE_OUTPUT_PATH}/renderdoc.dll
#)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${contain_sources})
message(STATUS "CMAKE_CURRENT_SOURCE_DIR:" ${CMAKE_CURRENT_SOURCE_DIR})

if (WIN32)#每次编译都更新资源文件
    # This has to be a separate target due to the windows command line lenght limits
    add_custom_target(EngineDllsCopy ALL DEPENDS ${projectName})#target in exe cmakelist
    set_target_properties(EngineDllsCopy PROPERTIES FOLDER "Script")
    if (CMAKE_CONFIGURATION_TYPES)
        foreach (CONF ${CMAKE_CONFIGURATION_TYPES})
            file(TO_NATIVE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CONF}" WIN_CONF_OUTPUT_DIR)
            file(TO_NATIVE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CONF}/Resources" WIN_RESOURCES_SYMLINK)
            message(STATUS "first WIN_CONF_OUTPUT_DIR:${WIN_CONF_OUTPUT_DIR}")
            message(STATUS "first WIN_RESOURCES_SYMLINK:${WIN_RESOURCES_SYMLINK}")
            message(STATUS "first ENGINE_RESOURCES_DIR_WIN:${ENGINE_RESOURCES_DIR_WIN}")
            add_custom_command(TARGET ${projectName} POST_BUILD#if exist "${WIN_CONF_OUTPUT_DIR}" "("
                COMMAND if not exist "${WIN_RESOURCES_SYMLINK}" "("
                            mklink /J "${WIN_RESOURCES_SYMLINK}" "${ENGINE_RESOURCES_DIR_WIN}"
                        ")"
                    #")"
                COMMENT "Symlinking the resources directory into the build tree"
                VERBATIM
            )
        endforeach ()

        #if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
            #bambustudio_copy_dlls(EngineDllsCopy "Debug" "d" output_dlls_Debug)
        #elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
            #bambustudio_copy_dlls(EngineDllsCopy "RelWithDebInfo" "" output_dlls_RelWithDebInfo)
        #else()
           #bambustudio_copy_dlls(EngineDllsCopy "Release" "" output_dlls_Release)
        #endif()
    else ()#CMAKE_RUNTIME_OUTPUT_DIRECTORY replace CMAKE_CURRENT_BINARY_DIR
        file(TO_NATIVE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Resources" WIN_RESOURCES_SYMLINK)
        message(STATUS "look WIN_RESOURCES_SYMLINK:${WIN_RESOURCES_SYMLINK}")
        message(STATUS "look ENGINE_RESOURCES_DIR_WIN:${ENGINE_RESOURCES_DIR_WIN}")
        add_custom_command(TARGET ${projectName} POST_BUILD
            COMMAND if not exist "${WIN_RESOURCES_SYMLINK}" "(" mklink /J "${WIN_RESOURCES_SYMLINK}" "${ENGINE_RESOURCES_DIR_WIN}" ")"
            COMMENT "Symlinking the resources directory into the build tree"
            VERBATIM
        )
    endif ()
endif ()


